package engine.systems.timeline.timelineClip
{
	import engine.classes.enumerations.SystemPriority;
	import engine.systems.timeline.timeline.FrameData;
	import engine.systems.timeline.timeline.FrameEvent;
	import engine.systems.timeline.timeline.Timeline;
	import engine.systems.update.GameSystem;
	import engine.utils.DataUtils;
	
	import flash.display.MovieClip;
	
	public class TimelineClipSystem extends GameSystem
	{
		public function TimelineClipSystem()
		{
			super(TimelineClipNode, updateNode, nodeAdded);
			
			this.priority = SystemPriority.POST_TIMELINE;
		}
		
		private function updateNode(node:TimelineClipNode, time:Number):void
		{
			if(node.timeline.locked) return;
			
			var clip:MovieClip 	= node.render.display as MovieClip;
			var frame:int 		= node.timeline.frame;
			
			if(frame == clip.currentFrame) return;
			clip.gotoAndStop(frame);
		}
		
		private function nodeAdded(node:TimelineClipNode):void
		{
			node.timeline.parseClip(node.render.display as MovieClip);
		}
	}
}